<%@ include file="/common/taglibs.jsp"%>
<%
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevent caching at the proxy server
%>

<head>
    <title><fmt:message key="busquedaarticulosForm.title"/></title>
    <meta name="heading" content="<fmt:message key='busquedaarticulosForm.heading'/>"/>
</head>

<form:form id="busquedapreciosForm">

	<fieldset style="width: 300px">
	<legend><fmt:message key="common.filtros.busqueda"/></legend>
	
		<br/><div>
			<fmt:message key="common.articulo"/><br/>
			<input id="txtArticulo_id" class="text medium" maxlength="50"/>
		</div><br/>
		
		<div>
			<fmt:message key="common.codigo.articulo"/><br/>
			<input id="txtCodigoArticulo_id" class="text medium" maxlength="6"/>
		</div><br/>
	
		<div>
			<fmt:message key="common.categoria"/><br/>
			<select class="text mediumlarge" id="cmbCategoria_id">
				<option value="-1">
					<fmt:message key="label.itemdefault"/>
				</option>
				<c:forEach var="categoria" items="${listacategorias}">	
					<option value="${categoria.id}">
						${categoria.deCategoria}
					</option>
				</c:forEach>			
			</select>
		</div><br/>
		
		<div>
			<fmt:message key="common.maneja.stock"/><br/>
			<select id="stManejaStock" name="stManejaStock" class="text mediumlarge">
				<option value="-1"><fmt:message key="label.itemdefault"/></option>
				<option value="PC"><fmt:message key="common.maneja.stock.punto.canje"/></option>
				<option value="AP"><fmt:message key="common.maneja.stock.almacen.principal"/></option>
				<option value="IN"><fmt:message key="common.maneja.premioinstantaneo"/></option>
			</select>
		</div><br/>
		
		<div>
			<fmt:message key="common.maneja.serie"/><br/>
	        <select class="text mediumlarge" id="stManejaSerie" >
	        	<option value="-1"><fmt:message key="label.itemdefault"/></option>
				<option value="Y"><fmt:message key="common.yes"/></option>
				<option value="N"><fmt:message key="common.no"/></option>
	       	</select>
		</div><br/>
		
		<div>
			<input type="button" onclick="buscarArticulo()" 
			value="<fmt:message key="button.search"/>"/>
		</div>	
	</fieldset><br/><br/>

	<table cellpadding="0" class="table" cellspacing="0" style="width: 900px">
		<thead> 
			<tr> 
	            <th scope="col"><fmt:message key="common.articulo"/></th>
	            <th scope="col"><fmt:message key="common.categoria"/></th>
	            <th scope="col"><fmt:message key="common.codigo.articulo"/></th>
	            <th scope="col"><fmt:message key="common.unidad.medida"/></th>
	            <th scope="col"><fmt:message key="common.maneja.tipoarticulo"/>?</th>            
	            <th scope="col"><fmt:message key="common.stock.actual"/></th>            
	            <th scope="col"><fmt:message key="common.stock.disponible"/></th>		
			</tr>
		</thead>
		<tbody id="busquedaarticulobody">
	
				<tr id="pattern" style="display:none;">
					<td><span id="tableArticulo"></span></td>
					<td><span id="tableCategoria"></span></td>
					<td><span id="tableCodigoArticulo"></span></td>
					<td><span id="tableUnidadMedida"></span></td>
					<td><span id="tableManejaStock"></span></td>
					<td><span id="tableStockActual"></span></td>
					<td><span id="tableStockDisponible"></span></td>
				</tr>	
				<c:forEach var="bnarticulo" items="${listaarticulos}" varStatus="status">	
					<c:choose>
						  <c:when test="${status.index % 2 == 0}"><tr class="odd" ></c:when>
						  <c:otherwise><tr class="even" ></c:otherwise>
					</c:choose>
					
					<td><a href="javascript:void(0)" onClick="Modalbox.hide({beforeHide: function(){				
							$('deArticuloID').value 	  = '${bnarticulo.deArticulo}',
							$('coArticuloID').value 	  = '${bnarticulo.coArticulo}',				
							$('deUnidadMedidaID').value   = '${bnarticulo.deUnidadMedida}',
							$('coCodigoArticuloID').value = '${bnarticulo.coCodigoArticulo}',
							$('stManejaStockPuntoCanjeID').value   = '${bnarticulo.stManejaStockPuntoCanje}',
							$('stInstantaneoNormalID').value   = '${bnarticulo.stInstantaneoNormal}',
							$('stManejaStockAlmPrincipalID').value = '${bnarticulo.stManejaStockAlmPrincipal}'}})">				
		                	${bnarticulo.deArticulo}
		                </a></td>
					<td>${bnarticulo.deCategoria}</td>
					<td>${bnarticulo.coCodigoArticulo}</td>
					<td>${bnarticulo.deUnidadMedida}</td>
					
					<td><c:choose>
		               		<c:when test="${bnarticulo.stManejaStockPuntoCanje == 'Y'}">
		               			<fmt:message key='common.maneja.stock.punto.canje'/>
		               		</c:when>
		               		
		               		<c:when test="${bnarticulo.stManejaStockAlmPrincipal == 'Y'}">
		               			<fmt:message key='common.maneja.stock.almacen.principal'/>
		               		</c:when>
		               		
		               		<c:when test="${bnarticulo.stInstantaneoNormal == 'Y'}">
		               			<fmt:message key='common.maneja.premioinstantaneo'/>
		               		</c:when>
		                </c:choose>
		            </td>
		            
		            <td>${bnarticulo.vaStockActual}</td>
		            <td>${bnarticulo.vaStockDisponible}</td>
					
					</tr>
		        </c:forEach>
	
		</tbody>
	</table>

</form:form>
